package com.hbnu.collection;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author kittychen
 * @since 2025-10-17 8:56
 */
public class HashMapDemo {
    public static void main(String[] args) {
        Map<String, String> hashMap = new HashMap<>();

        hashMap.put("name", "kittychen");
        hashMap.put("age", "18");
        hashMap.put("address", "湖北黄石");

        System.out.println(hashMap);
        System.out.println(hashMap.get("name"));

        // hashMap.remove("name");

        // hashMap.clear();

        Set<String> keySet = hashMap.keySet();  // 获取所有的key
        for (String key : keySet) {
            System.out.println(key + " = " + hashMap.get(key));
        }

        Collection<String> values = hashMap.values();  // 获取所有的value
        for (String value : values) {
            System.out.println(value);
        }
    }
}
